package com.hxzy.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.context.annotation.Lazy;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

@Data
/**
 * Entity这一个可持久化的对象，有这个注解，就可以对数据库进行增删改查操作
 */
@Entity
/**
 * 指定数据库表名, 根据mybatis-plus @TableName作用相同
 */
@Table(name = "goods_info")
public class GoodsInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 商品表主键id
     */
    @Id
    @Column(name = "goods_id", nullable = false)
    /**
     * 主键生成策略 自增长
     */
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long goodsId;

    /**
     * 商品名
     */
    @Column(name = "goods_name", nullable = false)
    private String goodsName;

    /**
     * 商品简介
     */
    @Column(name = "goods_intro", nullable = false)
    private String goodsIntro;

    /**
     * 关联分类id
     */
    @Column(name = "goods_category_id", nullable = false)
    private Long goodsCategoryId;

    /**
     * 商品主图
     */
    @Column(name = "goods_cover_img", nullable = false)
    private String goodsCoverImg;

    /**
     * 商品轮播图
     */
    @Column(name = "goods_carousel", nullable = false)
    private String goodsCarousel;

    /**
     * 商品详情(延迟加载)
     */
    @Basic(fetch = FetchType.LAZY)
    @Column(name = "goods_detail_content", nullable = false, columnDefinition = "Text")
    private String goodsDetailContent;

    /**
     * 商品价格
     */
    @Column(name = "original_price", nullable = false)
    private Integer originalPrice;

    /**
     * 商品实际售价
     */
    @Column(name = "selling_price", nullable = false)
    private Integer sellingPrice;

    /**
     * 商品库存数量
     */
    @Column(name = "stock_num", nullable = false)
    private Integer stockNum;

    /**
     * 商品上架状态 0-下架 1-上架
     */
    @Column(name = "goods_sell_status", nullable = false)
    private Integer goodsSellStatus;

    /**
     * 添加者主键id
     */
    @Column(name = "create_user", nullable = false)
    private Integer createUser;

    /**
     * 商品添加时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @Column(name = "create_time", nullable = false)
    private Date createTime;

    /**
     * 修改者主键id
     */
    @Column(name = "update_user")
    private Integer updateUser;

    /**
     * 商品修改时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @Column(name = "update_time")
    private Date updateTime;

}
